/*
 * Created by SharpDevelop.
 * User: MyWife
 * Date: 6/17/2009
 * Time: 7:44 AM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using popLib;
using popLib.ExtensionClass;


namespace MailCheckerGadget
{
	/// <summary>
	/// Description of Options.
	/// </summary>
	public partial class Options : SidebarGadgetOption
	{
		public Options(SidebarGadget sidebarGadget):base(sidebarGadget)
		{
			InitializeComponent();			
			this.txt_host.Text 	 = sidebarGadget.Options[Start.optionsType.Host+""]+"";
			this.txt_id.Text 	 = sidebarGadget.Options[Start.optionsType.Username+""]+"";
			this.txt_pw.Text 	 = sidebarGadget.Options[Start.optionsType.Password+""]+"";
			this.cbx_ssl.Checked = (sidebarGadget.Options[Start.optionsType.SSL+""]+"" == "1") ? true : false;
			this.cbx_inform.Checked = (sidebarGadget.Options[Start.optionsType.AlwaysNotifyNewMail+""]+"" == "1") ? true : false;
			try{
				this.nud_timer.Value= Convert.ToInt16( sidebarGadget.Options[Start.optionsType.RequestDelay+""]+"" ) ;
			}catch{ this.nud_timer.Value = nud_timer.Minimum; }
		}
		
		void Btn_cancelClick(object sender, EventArgs e)
		{
			this.Hide();
		}
		
		void Btn_okClick(object sender, EventArgs e)
		{
			Hashtable options = sidebarGadget.Options;
			options[Start.optionsType.Host+""] = txt_host.Text;
			options[Start.optionsType.Username+""] = txt_id.Text;
			options[Start.optionsType.Password+""] = txt_pw.Text;
			options[Start.optionsType.SSL+""] 	   				= cbx_ssl.Checked ? 1 : 0 ;
			options[Start.optionsType.AlwaysNotifyNewMail+""] 	= cbx_inform.Checked ? 1 : 0 ;
			options[Start.optionsType.RequestDelay+""] = nud_timer.Value;
			sidebarGadget.Options = options;
			this.Hide();
		}
	}
}
